﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteMaster.Master"
    Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="Microhard.Framework.MVCHelper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    门店图片
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="section-header">
        <div class="title">
            <img src="<%=Url.Content("~/Content/images/ico-catalog.png")%>" alt="" />
            门店图片
        </div>
        <div class="options">
        </div>
    </div>
    <table width="100%">
        <tr>
            <td class="adminTitle">
                <img alt="客户" src="<%=Url.Content("~/Content/images/ico-help.gif") %>" title="客户" /><label
                    for="operationName" title="客户">客户</label>
            </td>
            <td class="adminData">
                <%Html.RenderAction("GetKAList", "FMCGTool", new { area = "Tools", ctrAttr = new Microhard.WebUI.Models.AttriubteOfSelectList { ParameterModelName = "SelectedKAID", IsMulitiplySelect = false, DefaultSelectedText = "请选择", DefaultSelectedValue = "0" } });%>
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                <img alt="门店" src="<%=Url.Content("~/Content/images/ico-help.gif") %>" title="门店" /><label
                    for="operationName" title="门店">门店</label>
            </td>
            <td class="adminData">
                <%=Html.Telerik().ComboBox().Name("SelectSubKACode")%>
            </td>
        </tr>
    </table>
    <p>
    </p>
    <table class="adminContent">
        <tr>
            <td>
                <%Html.Telerik().Grid<Micrhard.FMCG.Server.Models.ProductDisplayImageModel>((List<Micrhard.FMCG.Server.Models.ProductDisplayImageModel>)this.Model.Data)
                    .Name("operation-grid")
                    .ToolBar(t => t.Template(g =>
                    { %>
                <%var searchParms = new Dictionary<string, string>();
                  searchParms.Add("KAID", "SelectedKAID");
                  searchParms.Add("SubKACode", "SelectSubKACode");
                %>
                <div class="header-menu">
                    <ul class="t-widget t-reset t-header t-menu">
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_SearchButton("btnSearch", "查询", "operation-grid", searchParms, "OperationGridOnGridDataBinding")%>
                        </li>
                        <li class="t-item  t-state-default">
                            <%=Html.Authorized_DeleteButton("btnDelete", "删除", "operation-grid", "DeleteImage", "KAPrdDisplay", "FMCGClient")%>
                        </li>
                    </ul>
                </div>
                <%}))
                         .ClientEvents(events => events.OnDataBinding("OperationGridOnGridDataBinding"))
                         .Columns(columns =>
                    {
                        columns.Bound(x => x.ImageID)
                       .Template(x => Html.CheckBox("checkedRecords", new { value = x.ImageID, @class = "gridCks" }))
                       .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= ImageID #>' class='gridCks'/>")
                     .HtmlAttributes(new { style = "text-align:center" }).Title("选择");
                        
                       columns.Bound(x => x.ImageID)
                         .Template(c => {
                %>
                <img alt="<%= c.ImageID %>" src="GetPrdDisplayImage?identity=<%= c.ImageID %>" width="440"
                    height="390" />
                <%
                         }).ClientTemplate("<img src='GetPrdDisplayImage?identity=<#= ImageID #>'alt='<#= ImageID #>' width='440' height='390'/>")
                       .HtmlAttributes(new { style = "text-align:center" }).Title("图片");
                       columns.Bound(x => x.PrdDispKACode).Title("陈列码");
                       columns.Bound(x => x.CreateTime).Title("上传时间");
                    })
                      .Pageable(settings => settings.Total(Model.Total).PageSize(Html.GetGridPageSize()).Position(GridPagerPosition.Top))
                      //绑定搜索按钮，执行对应的action
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_List", "KAPrdDisplay"))
                    .EnableCustomBinding(true)
                    .Render();
                %>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            function BindSubKA(kaid) {
                var combobox = $('#SelectSubKACode').data('tComboBox');
                //从ka选择中获取卖场
                var url = '../SubKA/_GetSubKAByKAID?identity=' + kaid;
                $.getJSON(url).done(function (data) {
                    combobox.dataBind(data);
                }).fail(function (jqxhr, textStatus, error) {
                    alert(error);
                });
            }
            $('#SelectedKAID').change(function (e) {
                var kaid = $('#SelectedKAID').val();
                BindSubKA(kaid);
            });
        });
    </script>
</asp:Content>
